//
//  TSPraiseEditContentController.m
//  chart
//
//  Created by 曾斌 on 16/4/14.
//  Copyright (c) 2016年 xu. All rights reserved.
//

#import "TSPraiseEditContentController.h"
#import "TSTaskModel.h"
#import "TSTools.h"
#import "TSPraiseController.h"
@implementation TSPraiseEditContentController
{
    TSTaskModel *taskModel;
}
@synthesize taskId;

-(void)initLeftButton{
     WS(weakSelf);
    [self leftBarButtonWithTitle:nil barNorImage:[UIImage imageNamed:@"nav_dark_close"] barHltImage:nil action:^{
        if (!weakSelf) {
            return;
        }
        [weakSelf.navigationController popViewControllerAnimated:YES];
    }];
}
-(void) initTitle{
    self.title =@"点赞内容";
    WS(weakSelf);
    [self rightBarButtonWithTitle:@"确认" barNorImage:nil barHltImage:nil action:^{
        if (!weakSelf) {
            return;
        }
        [weakSelf rightClick];
    }];
    
}

-(void)rightClick
{
    /*点赞*/
    WS(weakSelf);
    taskModel = [[TSTaskModel alloc] init];
    taskModel.requestParams = @{@"id":taskId,@"content": [self.textField text]};
    [taskModel fetchWithPath:kRequestUrl_Task_action_praise completionHandler:^(BOOL isSucceeded, NSError *error) {
        [TSTools showAlert:@"点赞成功"];
        NSArray * cols = weakSelf.navigationController.viewControllers;
        TSPraiseController * c=[cols objectAtIndex:[cols count]-3];
        [weakSelf.navigationController popToViewController:c animated:YES];
        [c.tableView.header beginRefreshing];
        
    } NoProgress:NO];
}

@end
